From e017af9ee09e7127a70b6ae6fe9da3aa2587aff0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Florian=20M=C3=BCllner?= Date: Sat, 25 Apr 2026 00:19:36 +0200 Subject: [PATCH] shell/app: Be extra careful when applying GPU environment We get the environment from SwitcherooControl as an array of key-value pairs. When applying it, we loop over the array in pairs, assuming that every key has a value. While this is the expected format, it does not hurt to be defensive against possible bugs in the service, so explicitly check that both key and value are non-NULL before applying them. Spotted by papagai. Part-of: --- src/shell-app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shell-app.c b/src/shell-app.c index ed7ecfffe..acb996c0b 100644 --- a/src/shell-app.c +++ b/src/shell-app.c @@ -1338,7 +1338,7 @@ apply_discrete_gpu_env (GAppLaunchContext *context, continue; env_s = g_variant_get_strv (env, NULL); - for (j = 0; env_s[j] != NULL; j = j + 2) + for (j = 0; env_s[j] != NULL && env_s[j+1] != NULL; j = j + 2) g_app_launch_context_setenv (context, env_s[j], env_s[j+1]); return; } -- 2.39.5